<template>
	<view>
		<view class="top-view">
			<!-- 			<uni-nav-bar
				title="评价我的"
				backgroundColor="transparent"
				:shadow="false"
				:border="false"
				:statusBar="true"
				leftIcon="back"
				@clickLeft="navBack"
				color="black">
			</uni-nav-bar> -->
		</view>
		<view class="container">
			<view class="top-card-view">
				<view class="top-card">
					<view class="balance-row">
						<view class="left">
							<view class="title">
								我的平均分
							</view>
							<view class="score">

								<view class="unit">分</view>
							</view>
						</view>
					</view>

					<view class="total-row">
						<view class="total-item">
							<view class="title">
								总评分
							</view>
							<view class="score"></view>
						</view>

						<view class="total-item right-item">
							<view class="title">
								总评价次数
							</view>
							<view class="score"></view>
						</view>

					</view>

				</view>
			</view>


			<view class="table-view">
				<view class="title">评价明细</view>
				<view class="date-row">
					<view class="left">
						<picker mode="date" fields="month" @change="onDateChange">
							{{date.format('yyyy年MM月')}}
							<uni-icons type="bottom"></uni-icons>
						</picker>
					</view>
					<view class="right">
						<view class="item">总评分：{{dataDetails.evaluationCnt}}</view>
						<view class="item">评价次数：{{dataDetails.totalEvaluationScore}}</view>
					</view>
				</view>
				<view class="item-row" v-for="(item,index) in dataDetails.rows">
					<view class="date">
						<view class="day">{{item.orderDatePart}}</view>
						<view class="week">{{item.weekDate}}</view>
					</view>
					<view class="left">
						<view class="name">评价人：{{item.visitor}}</view>
						<view class="order">订单 {{item.orderNum}}</view>
					</view>
					<view class="right score-text">{{item.comprehensiveServices}}</view>
				</view>

			</view>

		</view>
	</view>
</template>

<script>
	import * as orderInfo from '../../common/api/orderInfo.js'
	export default {
		data() {
			return {
				date: null,
				dataDetails: {}
			}
		},
		onLoad() {
			this.date = new Date()
		},
		onShow() {
			this.getData()
		},
		methods: {
			navBack() {
				uni.navigateBack()
			},
			onDateChange(e) {
				console.log(e);
				this.date = new Date(e.detail.value)
				this.getData()
			},
			getData() {
				const dataJson = uni.getStorageSync('user_info') || '{}'
				console.log('user_info dataJson', dataJson);
				const data = JSON.parse(dataJson) || {}
				const param = {
					dispatchNursesUid: data.nurseUid,
					monthTime: this.date.format('yyyy-MM')
				}
				orderInfo.queryPatientEvaluationBy(param).then(result => {
					this.dataDetails = result.data.data || {}
				}).catch(error => {
					console.log(error);
				})
			}
		}
	}
</script>

<style>
	page {
		background: white;
	}
</style>
<style lang="scss" scoped>
	.top-view {
		height: 700rpx;
		background: linear-gradient(to bottom, rgba(207, 234, 238, 1), rgba(207, 234, 238, 0));
	}

	.container {
		// margin-top: -560rpx;
		margin-top: -660rpx;
		display: flex;
		flex-direction: column;
	}

	.top-card-view {
		display: flex;
		align-items: center;
		justify-content: center;

		.top-card {
			width: 686rpx;
			height: 352rpx;
			background: url('../../static/wallet_pic.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
			display: flex;
			flex-direction: column;
			padding: 36rpx 40rpx;
			box-sizing: border-box;

			.balance-row {
				display: flex;
				align-items: flex-end;

				.left {
					flex: 1;
					color: white;

					.title {
						font-size: 30rpx;
						display: flex;
						align-items: center;
						font-size: 500;
					}

					.score {
						font-size: 64rpx;
						font-weight: bold;
						margin-top: 12rpx;
						line-height: 76rpx;
						display: flex;
						align-items: flex-end;

						.unit {
							font-size: 22rpx;
							font-size: 400;
							line-height: 50rpx;
						}
					}
				}
			}


			.total-row {
				display: flex;
				flex: 1;
				align-items: flex-end;

				.total-item {
					width: 100%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					color: white;

					.title {
						font-size: 30rpx;
						font-weight: 500;
						display: flex;
						align-items: center;
					}

					.score {
						line-height: 52rpx;
						font-size: 44rpx;
						font-weight: 600;
					}
				}

				.right-item {
					align-items: center;
				}
			}


		}
	}

	.table-view {
		width: 100%;
		display: flex;
		flex-direction: column;
		background: white;
		padding: 40rpx;
		box-sizing: border-box;
		margin-top: 44rpx;

		.title {
			color: #232323;
			font-size: 32rpx;
			font-weight: 600;
		}

		.date-row {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 32rpx;

			.left {
				font-size: 36rpx;
				color: #232323;
				display: flex;
				align-items: center;
			}

			.right {
				display: flex;
				align-items: center;

				.item {
					margin-left: 24rpx;
					color: #232323;
					font-size: 24rpx;
				}
			}
		}

		.item-row {
			min-height: 146rpx;
			border-bottom: solid 2rpx #F8F8F8;
			display: flex;
			align-items: center;

			.date {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.day {
					font-size: 40rpx;
					font-weight: bold;
					color: #232323;
				}

				.week {
					font-size: 30rpx;
					color: #232323;
				}
			}

			.left {
				flex: 1;
				margin-left: 20rpx;

				.name {
					color: #232323;
					font-size: 32rpx;
					font-weight: 400;
				}

				.order {
					color: rgba(35, 35, 35, 0.5);
					font-size: 24rpx;
					font-weight: 400;
					margin-top: 10rpx;
				}
			}

			.right {
				font-size: 36rpx;
				font-weight: 500;
			}

			.score-text {
				color: #E30E0E;
			}
		}

	}
</style>